<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<link href="<%=request.getContextPath()%>/css/css.css" rel="stylesheet">
<title>Insert title here</title>
</head>

<script src="/vandor/jquery/jquery.min.js"></script>

<script type="text/javascript">

function delete1(mid){
	
	$.post("todelete",{mid:mid},function(obj){
		
		if(obj>0){
			
			alert("删除成功!");
			
			location = "list";
			
		}else
			{
			
				alert("删除失败!");
			
			}
		
	})
	
}

function delall(){
	
	var ck = new Array();
	
	$("[name='ck']:checked").each(function(){
		
		ck.push($(this).val());
		
	});
	
	if(ck.length==0){
		
		alert("请选择一条记录!");
		
	}else if(confirm("是否确认删除?")){
		
		$.post("deleteAll",$("#del").serialize(),function(obj){
			
			if(obj>0){
				
				alert("删除成功！");
				
				location = "list";
				
			}else
				{
					
				alert("删除失败！");
				
				
				location = "list"; 
				
				}
			
		})
		
	}
	
}

function qx(){
	
	var ck = $("[name='ck']");
	
	for(var i=0;i<ck.length;i++){
		
		ck[i].checked=true;
		
	}
	
}

function qbx(){
	
	var ck = $("[name='ck']");
	
	for(var i=0;i<ck.length;i++){
		
		ck[i].checked=false;
		
	}
	
}

function fx(){
	
	var ck = $("[name='ck']");
	
	for(var i=0;i<ck.length;i++){
		
		if(ck[i].checked==true){
			
			ck[i].checked=false;
			
		}else
			{
			ck[i].checked=true;
			
			}
		
	}
	
}

function page(cpage){
	
	$("[name='cpage']").val(cpage);
	
	$("#xul").submit();
	
}


</script>

<body>

<form action="list" method="post" id="xul">

<input type="hidden" name="cpage" value="${page.pageNum }">
<input type="text" name="mname" value="${map.mname }"><br>

<button>查询</button>

</form>

<form action="list" method="post" id="del">

<table>

	<tr>
	
		<td>请选择</td>
		<td>序号</td>
		<td>影片名称</td>
		<td>介绍</td>
		<td>
		
			<input type="button" value="添加" onclick="location='toadd'">
		
		</td>
	
	</tr>
	
		<c:forEach items="${list}" var="movie">
		
			<tr>
			
				<td>
				
					<input type="checkbox" name="ck" value="${movie.mid }">
				
				</td>
				<td>${movie.mid }</td>
				<td>${movie.mname }</td>
				<td>${movie.introduction }</td>
				<td>
				
					<input type="button" value="删除" onclick="delete1(${movie.mid})">
					<input type="button" value="修改" onclick="location='toupdate?mid=${movie.mid}'">
					<input type="button" value="查看" onclick="location='tolook?mid=${movie.mid}'">
					
				</td>
			
			</tr>
		
		</c:forEach>
		
			<tr>
			
				<td colspan="7">
				
					<input type="button" value="批量删除" onclick="delall()">
					<input type="button" value="全选" onclick="qx()">
					<input type="button" value="全不选" onclick="qbx()">
					<input type="button" value="反选" onclick="fx()">
				
				</td>
			
			</tr>
			
			<tr>
			
				<td colspan="7">
				
					<input type="button" value="首頁" onclick="page('1')">
					<input type="button" value="上一頁" onclick="page('${page.pageNum-1}')">
					<input type="button" value="下一頁" onclick="page('${page.pageNum+1}')">
					<input type="button" value="尾頁" onclick="page('${page.pages}')">
					
						总:${page.pageNum }/${page.pages }页
				
				</td>
			
			</tr>

</table>

</form>

</body>
</html>